table.INDEX_GET Function

Syntax

as P = Index_Get(C tagname)

Arguments

tagname

The name of an index or query list description.

Description

Returns an index given a name.

Discussion

The .INDEX_GET() method returns an pointer to an index or query list specified by Tag_Name for a table. Once you have a reference to an index tag or query list, you can use the various methods for an index pointer (such as .RECORDS_GET()to determine the number of records in the index tag or query list). If the index tag is not found in the index file or the query list does not exist,the method returns the closest match, as shown below:. Note : The .INDEX_GET() method does not set Tag_Name as the primary index.

idxtbl = table.open("maint_bills_test", FILE_RW_SHARED) 
 indx = idxtbl.index_get("facility")
  
? indx.name_get() 
 = "Facil"

Example

This script sets the primary index to Lastname.

dim tbl as P
tbl = table.current()
indx = tbl.index_get("Lastname")
tbl.index_primary_put(indx)

Since <TBL>.INDEX_PRIMARY_PUT() also can take a tag name as an argument, this script could be written more simply as follows.

dim tbl as P
tbl = table.current()
tbl.index_primary_put("Lastname")

This script gets a count of the number of keys in an index tag.

dim tbl as P
tbl = table.current()
indx = tbl.index_get("CA Customers")
count = indx.records_get()

See Also